package com.bizihang.common.security.core.authorize;

import com.bizihang.common.security.core.SecurityConstants;
import org.springframework.core.annotation.Order;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
import org.springframework.stereotype.Component;

/**
 * 认证服务器模块的授权配置
 *
 * @author 毕子航 951755883@qq.com
 * @date 2018/10/20
 */
@Component("authenticationModularAuthorizeConfig")
@Order(Integer.MIN_VALUE)
public class AuthenticationProvider implements AuthorizeProvider {

	/**
	 * 不需要授权的url配置
	 *
	 * @param config the config
	 * @return
	 */
	@Override
	public boolean config(ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry config) {
		config.antMatchers(SecurityConstants.DEFAULT_UNAUTHENTICATION_URL,
				SecurityConstants.DEFAULT_SIGN_IN_PROCESSING_URL_MOBILE,
				SecurityConstants.DEFAULT_SIGN_IN_PROCESSING_URL_OPENID,
				SecurityConstants.DEFAULT_SOCIAL_USER_INFO_URL,
				SecurityConstants.DEFAULT_VALIDATE_CODE_URL_PREFIX + "/*",
				"/druid/**", "/auth/**", "/swagger-ui.html", "/swagger-resources/**", "/v2/api-docs").permitAll();
		return false;
	}
}
